home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6572 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.7 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What to do when feof() is NOT feof()
  5. Date: 19 Feb 96 16:09:16 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.824746156@rscernix>
  8. References: <4g7rsj$fnf@spectator.cris.com> <1996Feb19.063026.29889@zcon.com> <4g9tph$5ss@spectator.cris.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4g9tph$5ss@spectator.cris.com> aubrey@concentric.net (Aubrey Harrison) writes:
  13.  
  14. >Once again, the original message did not indicate what OS or compiler the 
  15. >person was using. I should have been clearer in my response that I was 
  16. >referring to MS-DOS and Microsoft C. 
  17.  
  18. But you haven't.  And this is the point: you phrased your answer as if it
  19. were describing a general C feature, not an implementation detail on a
  20. certain platform.  The unsuspecting beginner reading your original post
  21. would be led to believe that this is how C works, and this is false.
  22.  
  23. >I only responded because I have had the 
  24. >exact same problem and tracked it down to the fact that while the file I was 
  25. >reading was a "text" file there were a few bytes (including ascii 26) that were 
  26. >killing fgets and signalling end-of-file when it was not.
  27.  
  28. This behaviour is allowed by the standard whenever a non-printable 
  29. character (other than horizontal tab and newline) is read from a text 
  30. stream.
  31.  
  32. >Maybe he has some 
  33. >other problem, maybe he has the same problem. I don't know, and you don't know. 
  34.  
  35. This is precisely why you should have mentioned, as clearly as possible,
  36. that your advice applies ONLY to a certain platform (or set of platforms,
  37. the ^Z convention is inherited by MSDOS from CP/M-80, which actually
  38. _needed_ an end-of-file marker for text files).
  39.  
  40. Another point is that C doesn't give you the licence to open a file in
  41. whatever mode you want.  If the file was created with the "w" mode, it 
  42. has to be opened with the "r" mode.  Likewise, "wb" requires "rb".
  43. On many platforms, you can open the file with the 'wrong' mode and be able
  44. to access its contents (or part of it) with or without alterations, but
  45. the limitations of such an advice have also to be clearly stated.
  46.  
  47. >I think the notion that the only help that could or should ever be given is an 
  48. >exact diagnoses and cure to a problem is a little ridiculous and unpractical. 
  49.  
  50. It's neither ridiculous nor impractical.  If you aren't sure of your
  51. diagnosis and/or solution, let other people who _are_ sure to post.
  52. If the description of the problem is not clear enough (and this was the
  53. case with the post which started this thread), ask for the missing details.
  54.  
  55. Going ahead and posting a solution based on a set of _implicit_ assumptions
  56. and containing "I think" and "I believe" is below the standards we try to
  57. impose and maintain on this newsgroup.  It's neither ridiculous nor 
  58. impractical to ask a responder to check his facts before posting, instead
  59. of using ridiculous disclaimers a la "I'm no expert", "I think", "I believe",
  60. etc.  Most of us aren't experts, either, so we post when we know something
  61. and don't post when we don't know _for sure_.  When the solution is based
  62. on assumptions, because the problem was improperly formulated, these
  63. assumptions have to be clearly stated, preferably before the solution.
  64. This way, the limitations of the solutions will be clear for everybody
  65. and the solution won't have to be amended by other people.
  66.  
  67. The moral of this thread is that it isn't sufficient to want to be
  68. helpful, good intentions cannot supplement lack of clarity, partial truths
  69. or dead wrong solutions based on personal beliefs.
  70.  
  71. Dan
  72. --
  73. Dan Pop
  74. CERN, CN Division
  75. Email: danpop@mail.cern.ch 
  76. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  77.